﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Deamon
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new WindowSettingsHomeButtonModel
            {
                Content = "默认值",
                Icon = "M790.588235 133.029647a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529zM790.588235 835.764706a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529z",
                Description = "默认值默认值默认值默认值.",
            };
        }


        private void IconButtonDesc_Click(object sender, RoutedEventArgs e)
        {

        }

    }
    public class WindowSettingsHomeButtonModels : ObservableCollection<WindowSettingsHomeButtonModel>
    {
        public WindowSettingsHomeButtonModels()
        {
            Add(new WindowSettingsHomeButtonModel()
            {
                Content = "Home",
                Icon = "M790.588235 133.029647a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529zM790.588235 835.764706a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529z",
                Description = "Go to the home page of the application."
            });
            Add(new WindowSettingsHomeButtonModel()
            {
                Content = "个性化",
                Description = "背景、锁屏、颜色",
                Icon = "M790.588235 133.029647a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529zM790.588235 835.764706a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529z",

            });
        }
    }

    public class WindowSettingsHomeButtonModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler? PropertyChanged;
        public string content { get; set; }
        public string Content
        {
            get { return content; }
            set
            {
                content = value;
                OnPropertyChanged(nameof(Content));
            }
        }
        public Geometry IconData { get; set; }
        public string description { get; set; }
        public string Description
        {
            get { return description; }
            set
            {
                description = value;
                OnPropertyChanged(nameof(Description));
            }
        }
        public string icon { get; set; }
        public RealayCommand ShowCommand { get; set; }
        public string Icon
        {
            get { return icon; }
            set
            {
                icon = value;
                OnPropertyChanged(nameof(Icon));
            }
        }
        public WindowSettingsHomeButtonModel()
        {
            //Content = "Home";
            //Description = "Go to the home page of the application.";
            //Icon = "M922.582451 626.414551h-27.631422V262.703178c0-45.335998-36.227863-82.075555-82.177893-82.075555H212.454927c-22.105137 0-43.289226 8.391765-58.742355 23.742555-15.555467 15.453128-24.561263 36.125525-24.561263 58.333v363.711373h-25.379972c-19.341995 0-36.227863 15.146112-36.227863 34.488107V760.375775c0 45.745353 38.069958 83.098941 83.508295 83.09894h723.022187c46.052369 0 82.38257-37.455926 82.38257-83.09894v-99.473117c0.102339-19.341995-14.532081-34.488107-33.874075-34.488107zM199.150909 262.703178c0-6.959025 6.140316-11.461923 13.304018-11.461923h600.318209c7.368379 0 12.178293 4.912253 12.178293 11.461923v363.711373H199.150909V262.703178zM886.456926 760.375775c0 6.856686-5.219268 13.09934-12.38297 13.09934H151.051769c-6.856686 0-13.508695-5.935639-13.508695-13.09934v-63.859285h748.913852V760.375775z";
            //IconData = new GeometryGroup
            //{
            //    Children = new GeometryCollection
            //    {
            //        new RectangleGeometry(new Rect(0, 0, 24, 24)),
            //        new EllipseGeometry(new Point(12, 12), 10, 10)
            //    }
            //};
            //Task.Run(() =>
            //{
            //    // Simulate some work
            //    Thread.Sleep(4000);
            //    Content = "已改变";
            //    Icon = "M790.588235 133.029647a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529zM790.588235 835.764706a26.352941 26.352941 0 1 1 0 52.705882h-210.823529a26.352941 26.352941 0 1 1 0-52.705882h210.823529z";
            //    Description = "Updated description after some work.";
            //});
            ShowCommand = new RealayCommand(() =>
            {
                MessageBox.Show("按钮被点击了！", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
            });

        }

        /// <summary>
        /// 通知属性更改的事件。更新界面
        /// </summary>
        /// <param name="propertyName"></param>
        public void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

    public class RealayCommand : ICommand
    {
        public event EventHandler? CanExecuteChanged;
        private readonly Action mExecute;
        public RealayCommand(Action executeAct)
        {
            mExecute = executeAct;
        }
        public bool CanExecute(object? parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            mExecute?.Invoke();
        }
    }
}